# Maintainer: Richard Shaw <hobbes1069@gmail.com>

_realname=fltk
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
_pkgver=1.3.5
pkgver=${_pkgver//-/.}
pkgrel=1
pkgdesc="C++ user interface toolkit (mingw-w64)"
arch=('any')
url="https://www.fltk.org/"
license=('LGPLv2+ with exceptions')
depends=("${MINGW_PACKAGE_PREFIX}-expat"
         "${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-gettext"
         "${MINGW_PACKAGE_PREFIX}-libiconv"
         "${MINGW_PACKAGE_PREFIX}-libpng"
         "${MINGW_PACKAGE_PREFIX}-libjpeg-turbo"
         "${MINGW_PACKAGE_PREFIX}-zlib")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'staticlibs' 'buildflags')
source=("http://fltk.org/pub/fltk/${_pkgver%"-2"}/${_realname}-${_pkgver}-source.tar.gz")
sha256sums=('8729b2a055f38c1636ba20f749de0853384c1d3e9d1a6b8d4d1305143e115702')

build() {
  [[ -d ${srcdir}/build-${CARCH} ]] && rm -rf ${srcdir}/build-${CARCH}
  # Upstream uses a custom Makefile so out of source builds don't work.
  cp -rf ${_realname}-${_pkgver} build-${CARCH}
  cd build-${CARCH}
  ./configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --enable-shared

  make VERBOSE=1
}

package() {
  cd ${srcdir}/build-${CARCH}
  make DESTDIR="${pkgdir}" install
  install -Dm644 ../${_realname}-${_pkgver}/COPYING "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
